package com.jiang.books.service;

import java.math.BigInteger;
import java.util.List;
import java.util.Set;

import javax.validation.ConstraintViolation;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.jiang.books.domain.Author;
import com.jiang.books.domain.AuthorSearchCriteria;

public interface AuthorService {
	
	final static String ALL_AUTHOR_NATIVE_QUERY =
			"select id, first_name, last_name, country_id, version from jiang_author";

	// Find all Authors
	public List<Author> findAll();

	// Find a Author with with Awards and Books by id
	public Author findById(BigInteger id);
	public Author findByIdAndRevision(BigInteger id, int revision);
	public List<Author> findAuditById(BigInteger id);

	// Insert or update a Author	
	public Author save(Author author);
	
	// Delete a Author	
	public void delete(Author author);


	// CrudRepository
	// Find Authors by first name
	public List<Author> findByFirstName(String firstName);
	
	// Find Authors by first name and last name
	public List<Author> findByFirstNameAndLastName(String firstName, String lastName);	

	public Page<Author> findAllByPage(Pageable pageable);	
	
	
	// Find all Author by native query
	public List<Author> findByNativeQuery(String query);
		
	// Find Authors by criteria query
	public List<Author> findByCriteriaQuery(String firstName, String lastName);
	public Page<Author> findByCriteria(AuthorSearchCriteria searchCriteria, Pageable pageable);
	
	public Set<ConstraintViolation<Author>> validateAuthor(Author author);
	
	
	// Test
	// Find all Authors with Books	
	public List<Author> findAllWithBooks();
	// Find all Authors with Awards and Books	
	public List<Author> findAllWithDetail();
	
}